package com.huida.app.equal.lomboktest;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wangzhuangzhuang
 * @DESC:
 * @date 2022-01-02 20:58
 */
@Slf4j
public class LombokEquals {

	public static void main(String[] args) {
		LombokEquals le = new LombokEquals();
		le.test01();
		le.test02();
	}

	public void test01(){
		Person wangzz = new Person("wangzz", "001");
		Person felix = new Person("Felix", "001");
		log.info("wangzz.equals(felix) ? {}", wangzz.equals(felix));
	}

	public void test02(){
		Employee emp01 = new Employee("wangzz", "001", "huida");
		Employee emp02 = new Employee("Felix", "002", "baidu");
		log.info("emp01.equals(emp02) ? {}, ", emp01.equals(emp02));
	}

	@Data
	class Person{
		@EqualsAndHashCode.Exclude
		private String name;
		private String identity;

		public Person(String name, String identity){
			this.name = name;
			this.identity = identity;
		}
	}

	@Data
	@EqualsAndHashCode(callSuper = true)
	class Employee extends Person{
		private String company;
		public Employee(String name, String identity, String company){
			super(name, identity);
			this.company = company;
		}
	}

}